import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.io.File;

class ImageToolkit
{
	private static Color transparency = new Color(255,21,138);
	
	private ImageToolkit(){}
	public static BufferedImage loadImage(byte image[], boolean trans)
	{
		return loadImage(new ImageIcon(image),trans);
	}
	public static BufferedImage loadImage(String s, boolean trans)
	{
		return loadImage(new ImageIcon(s),trans);
	}
	
	private static BufferedImage loadImage(ImageIcon ii, boolean trans)
	{
		BufferedImage fromFile = new BufferedImage(ii.getImage().getWidth(null),ii.getImage().getHeight(null),BufferedImage.TYPE_INT_ARGB);
		BufferedImage end = new BufferedImage(ii.getImage().getWidth(null),ii.getImage().getHeight(null),BufferedImage.TYPE_INT_ARGB);
		
		fromFile.getGraphics().drawImage(ii.getImage(),0,0,null);
		
		for(int x = 0; x < fromFile.getWidth(null); x++)
		{
			for(int y = 0; y < fromFile.getHeight(null); y++)
			{
				if(!trans || fromFile.getRGB(x,y) != transparency.getRGB())
					end.setRGB(x,y,fromFile.getRGB(x,y));
				else
					end.setRGB(x,y,0);
			}
		}
		
		return end;
	}
	
	public static void setTransparencyColor(Color c)
	{
		transparency = c;
	}
	
	public static Color getTransparencyColor()
	{
		return transparency;
	}
}